<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

   <script src="/resources/Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script src="/resources/Scripts/jquery.easyui.min-1.3.5.js" type="text/javascript"></script>
    <script src="/resources/Scripts/jquery.datagrid.js" type="text/javascript"></script>
    <script src="/resources/Scripts/JScriptIndex.js" type="text/javascript"></script>
	<script src="/resources/Scripts/newadd.js" type="text/javascript"></script>
    <script src="/resources/Res/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
     <link href="/resources/Content/Default.css" rel="stylesheet" type="text/css" />
    <link href="/resources/Content/IndexStyle.css" rel="stylesheet" type="text/css" />

        <link href="/resources/Res/easyui/themes/icon.css" rel="stylesheet" type="text/css" />
         <link href="/resources/Res/easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <title>

</title>

     



<script type="text/javascript" src="/resources/Res/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">

.td1{
    border: 0px black solid;
    width: 80px;
    height: 60px;
    text-align: right;
}
.td2{
    border: 0px black solid;
    width: 150px;
    height: 60px;
    text-align: left;
}
put{
  width: 160px;
  height:20px;
}
.td3{
    width: 70px;
  
    height:30px;
    font-size:16px;
    line-height:30px;
    text-align: center;
    border:0;
    border-radius:15px 15px;
    box-shadow: 0 0 0 0;
    background:#eadfdf;
    font-style: oblique;
}
.td4{
	text-align: center;
}
.yanzheng{
 color: red;

}
</style>

<script type='text/javascript'>

function creatXHR(){
	   try{
		   //火狐,Opera 8.0+, Safari
		   xhr = new XMLHttpRequest();
	   }catch(e){
		   try{
			   //IE 早期版本 5
			   xhr = new ActiveXObject("Msxml2.XMLHTTP");
		   }catch(e){
			   try{
				   //IE
				   xhr = new ActiveXObject("Microsoft.XMLHTTP");
			    }catch(e){
			       alert("浏览器不支持AJAX!");
			       return false;
		        }
	        }
	   }
}

//学员编号验证
function statechange(){
	if(xhr.readyState == 4){
		//alert("请求已经完成！");
		var flag = xhr.responseText;
		//alert(flag);
		if(flag=="-1"){
			 document.getElementById("yanZhengNum").innerHTML ="学员编号已存在";
		}else{
			 document.getElementById("yanZhengNum").innerHTML ="学员编号可用";
		}
	}
}

function checkStuNum(){
	creatXHR();
	var num = document.getElementById("name").value;
	var url = '/StuNum?num='+num;
	
	xhr.onreadystatechange = statechange;
	xhr.open("post",url,true);
	xhr.send(null);
}

//档案编号验证
function statechanges(){
	if(xhr.readyState == 4){
		//alert("请求已经完成！");
		var flag = xhr.responseText;
		//alert(flag);
		if(flag=="-1"){
			 document.getElementById("yanZhengRecoderNum").innerHTML ="档案编号已存在";
		}else{
			 document.getElementById("yanZhengRecoderNum").innerHTML ="档案编号可用";
		}
	}
}

function checkRecNum(){
	creatXHR();
	var nums = document.getElementById("dang").value;
	var url = '/RecNum?nums='+nums;
	
	xhr.onreadystatechange = statechanges;
	xhr.open("post",url,true);
	xhr.send(null);
}

//验证是否存在
   function ajaxFroms() {
		
		  if ( document.getElementById("stuName").value == "") {
              $.messager.alert('系统提示：', '用户名未填写！', 'warning');
              return false;
          }
		  
		  if ( document.getElementById("dang").value == "") {
              $.messager.alert('系统提示：', '为选择性别！', 'warning');
              return false;
          }
		  if ( document.getElementById("body").value == "") {
              $.messager.alert('系统提示：', '班级未填写！', 'warning');
              return false;
          }
		  if ( document.getElementById("address").value == "") {
              $.messager.alert('系统提示：', '联系方式未填写！', 'warning');
              return false;
          }
		  if ( document.getElementById("fee").value == "") {
              $.messager.alert('系统提示：', '申请类型未填写！', 'warning');
              return false;
          }
		  if ( document.getElementById("live").value == "") {
              $.messager.alert('系统提示：', '用户名未填写！', 'warning');
              return false;
          }
		  if ( document.getElementById("time").value == "") {
              $.messager.alert('系统提示：', '居住地址未填写！', 'warning');
              return false;
          }
		
		
		var form = new FormData(document.getElementById("form1"));
		
		$.messager.confirm('添加学员信息', '您确定要添加该学员吗？', function(r){
			if (r){
				$.ajax({
					url : "/addStudent",
					type : "post",
					data:form,
	                processData:false,
	                contentType:false,
					success : function(result) {
						console.log(result.msg)
						if (result.msg =='OK') {
							//alert("haha");
							//window.location.href = 'javascript:history.go(-2)';
							parent.location.reload();
						}

					}
				});
			}
		});


	
	}
</script>

</head>
<body>
 <form id="form1" action="#" method="post" enctype="multipart/form-data">
	<div  style="width:900px;padding:10px;background:#fafafa;"    class="easyui-panel" title="添加学员">
	<table  style="width: 850px;height: 240px;">
		<tr>
		    <td class="td1"><label for="name">学员编号:</label></td>
			<td class="td2"><input type="text" id="name" name="stuId" onchange="checkStuNum();"><span id="yanZhengNum" style="color: red;"></span></td>
			<td class="td1"><label for="dang">档案编号:</label></td>
			<td class="td2"><input type="text" id="dang" name="stuRecoderId"  onchange="checkRecNum();"><span id="yanZhengRecoderNum" style="color: red;"></span></td>	
		</tr>
		<tr>
		    <td class="td1"><label for="stuName">学员姓名:</label></td>
			<td class="td2"><input type="text" id="stuName" name="stuName"><span class="yanzheng">*必填</span></td>
		    <td class="td1"><label for="dang">性别:</label></td>
			<td class="td2"><input type="radio" id="dang" name="stuSex" value="男" >男
			<input type="radio" id="dang" name="stuSex" value="女">女 &nbsp;&nbsp;&nbsp;<span class="yanzheng">*必填</span>
			</td>
			
		</tr>
		
		<tr>
		    <td class="td1"><label for="sex">身份证号:</label></td>
			<td class="td2"><input type="text" id="sex"  name="stuCardId"></td>
			<td class="td1"><label for="photo">学员照片:</label></td>
			<td class="td2"><input type="file" style="width: 150px;" name="stuPhoto"></td>
		</tr>
		<tr>
		    <td class="td1"><label for="body">班别:</label></td>
			<td class="td2">
			<select style="width: 173px;height: 21px" id="body" name="stuClassType">
			<option value="">请选择</option>
			<option value="c1普通班">c1普通班</option>
			<option value="c1贵宾班">c1贵宾班</option>
			<option value="c2普通班">c2普通班</option>
			<option value="c2贵宾班">c2贵宾班</option>
			</select><span class="yanzheng">*必填</span>
			
			</td>
			<td class="td1"><label for="datet">当前阶段:</label></td>
			<td class="td2"><input type="text" id="datet" name="stuNowLicence"></td>
			
		</tr>
		<tr>
		    <td class="td1"><label for="address">联系方式:</label></td>
			<td class="td2"><input type="text" id="address" name="stuPhone"><span class="yanzheng">*必填</span></td>
			<td class="td1"><label for="cla">准驾车型:</label></td>
			<td class="td2"><input type="text" id="cla" name="stuDriverType"></td>
		</tr>
		</table>
		<table style="width: 850px;height: 50px;" >
		<tr>
		    <td style="width: 100px;height: 50px; text-align: right;" ><label for="bz">备注:</label></td>
		    <td style="width: 292px;height: 50px;"><textarea  id="bz" name="stuNote"  style="width: 550px;height: 40px;"></textarea></td>
			
		</tr>
		</table>
		<table style="width: 850px; height: 330px;">
		<tr>
		    <td class="td1"><label for="fee">申请类型:</label></td>
			<td class="td2"><input type="text" id="fee" name="stuApplicationType"><span class="yanzheng">*必填</span></td>
			<td class="td1"><label for="nw">应收费用:</label></td>
			<td class="td2"><input type="text" id="nw" name="stuShouldCharge"></td>
		</tr>
		<tr>
			<td class="td1"><label for="now">实收费用:</label></td>
			<td class="td2"><input type="text" id="now" name="stuCharge"></td>
			<td class="td1"><label for="ty">体检医院:</label></td>
			<td class="td2"><input type="text" id="ty" name="stuMedicaHospital"></td>
		</tr>
		<tr>
		    <td class="td1"><label for="apply">工作单位:</label></td>
			<td class="td2"><input type="text" id="apply" name="stuWorkUnit"></td>
		    <td class="td1"><label for="live">家庭住址:</label></td>
			<td class="td2"><input type="text" id="live" name="stuAddress"><span class="yanzheng">*必填</span></td>
		</tr>
		<tr>
			
			<td class="td1"><label for="time">居住地址:</label></td>
			<td class="td2"><input type="text" id="time" name="stuResidenceAddress"><span class="yanzheng">*必填</span></td>
			<td class="td1"><label for="time">居住证号:</label></td>
			<td class="td2"><input type="text" id="time" name="stuResidenceId"></td>
		</tr>
		<tr>
			<td class="td1"><label for="live">报名分校:</label></td>
			<td class="td2"><input type="text" id="live" name="stuAssignsSchool"></td>
			<td class="td1"><label for="time">报名点:</label></td>
			<td class="td2"><input type="text" id="time" name="stuAssigns"></td>
			
		</tr>
		<tr>
		    <td class="td1"><label for="time">报名来源:</label></td>
			<td class="td2"><input type="text" id="time" name="stuAdmissions"></td>
		    <td class="td1"><label for="bzs">招生来源:</label></td>
			<td class="td2"><select name="stuOffer" style="width: 173px;height: 21px">
			<option value="">请选择</option>
			<option value="电视广告">电视广告</option>
			<option value="网站推广">网站推广</option>
			<option value="员工宣传">员工宣传</option>
			</select></td>
     		
		</tr>
		
		<tr>
		     <td class="td1"><label for="phone">是否本地:</label></td>
			 <td class="td2"><select name="stuIsLocal"  style="width: 173px;height: 21px">
			  <option value="">请选择</option>
			  <option value="是">是</option>
			  <option value="否">否</option>
			</select></td>
			<td class="td1"><label for="live">推荐人:</label></td>
			<td class="td2"><input type="text" id="live" name="stuReferees"></td>
		</tr>
		
		<tr>
			<td class="td1"></td>
			<td class="td2 td4" style="text-align: center;"><input type="button" class="td3" onclick="ajaxFroms();" value="添加"></td>
			<td class="td1"><input type="reset" class="td3" style="text-align: center;" value="取消"></td>
			<td class="td2 td4"><input type="button" class="td3" onclick="tabClose();" value="返回" ></td>
		</tr>
	</table>
	</div>
	</form>
	<script type="text/javascript">
	 function tabClose() {
         parent.closeCurrTab();
     }
	</script>
	
	
</body>
</html>